import asia.doing.entity.Article;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortByViews {


    public static void main(String[] args) {


        List<Article> articles = new ArrayList<Article>();
        for (Article article : articles) {
            article.setViews(article.getViews() + 1);
        }
        //根据views进行排序
        Collections.sort(articles, new Comparator<Article>() {
            @Override
            public int compare(Article a1, Article a2) {
                // Sort in descending order (highest views first)
                return Integer.compare(a2.getViews(), a1.getViews());
            }
        });


    }
}
